﻿using System;
using System.Web.SessionState;

using KLS.PPDS.Utilities;
using KLS.PPDS.Utility.Extension;
using KLS.PPDS.Utility.Http;



namespace KLS.PPDS.Utility
{
    public class CommonSession
    {
        

        private static HttpSessionState Session
        {
            get { return HttpHelper.Session; }
        }



        public static int UserId
        {
            get { return  Convert.ToInt32(Session[CommonConstant.UserId]??0); }
            set { Session[CommonConstant.UserId] = value; }
        }

        public static string UserName
        {
            get { return Convert.ToString(Session[CommonConstant.UserName]??string.Empty); }
            set { Session[CommonConstant.UserName] = value; }
        }


        public static int CompanyId
        {
            get { return Session[CommonConstant.CompanyId].ToInt32(); }
            set { Session[CommonConstant.CompanyId] = value; }
        }

        public static string CompanyName
        {
            get { return Convert.ToString(Session[CommonConstant.CompanyName]); }
            set { Session[CommonConstant.CompanyName] = value; }
        }

        public static string Language 
        {
            get { return Convert.ToString(Session[CommonConstant.Language]); }
            set { Session[CommonConstant.Language] = value; }
        }

        public static bool IsUserSuperAdmin
        {
            get { return (bool)Session[CommonConstant.IsUserSuperAdmin]; }
            set { Session[CommonConstant.IsUserSuperAdmin] = value; }
        }

        public static bool IsUserSuperAdminOrGraphic
        {
            get { return (bool)Session[CommonConstant.IsUserSuperAdminOrGraphic]; }
            set { Session[CommonConstant.IsUserSuperAdminOrGraphic] = value; }
        }

        public static bool IsUserEditor
        {
            get { return (bool)Session[CommonConstant.IsUserEditor]; }
            set { Session[CommonConstant.IsUserEditor] = value; }
        }

        public static bool IsUserJournalist
        {
            get { return (bool)Session[CommonConstant.IsUserJournalist]; }
            set { Session[CommonConstant.IsUserJournalist] = value; }
        }

        public static bool IsUserGraphicsDesigner
        {
            get { return (bool)Session[CommonConstant.IsUserGraphicsDesigner]; }
            set { Session[CommonConstant.IsUserGraphicsDesigner] = value; }
        }

        
        
        public static int PageSize
        {
            get 
            { 
                int pageSize = Session["PageSize"].ToInt32(20);
                if (pageSize <= 0)
                {
                    pageSize = 20;
                    PageSize = 20;
                }
                return pageSize;
            }
            set { Session["PageSize"] = value; }
        }
    }
}
